package com.thread;

import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerTCThread {

    public static void main(String[] args) {
        System.out.println("======服务端启动======");
        // 创建服务端对象,要实现多个客户端向服务器发送数据，需要多线程
        try(ServerSocket socketServer = new ServerSocket(9999)) {
            while (true) {
                Socket socket = socketServer.accept();
                new TCPthread(socket).start();
            }

        } catch (Exception e){
            System.out.println("数据接收失败！");
            e.printStackTrace();
        }
    }
}
